Skip to content

Return an optional instead of casting -1 into an enum#3539

Merged
Ghabry merged 1 commit into
EasyRPG:masterfrom
staticssleever668:fix_enum_cast_ub
May 1, 2026
Merged

Return an optional instead of casting -1 into an enum#3539
Ghabry merged 1 commit into
EasyRPG:masterfrom
staticssleever668:fix_enum_cast_ub

Conversation

@staticssleever668

Copy link
Copy Markdown
Contributor

For enums without a fixed underlying type, casting into them from numbers outside of their enumeration values is undefined behavior. Fixes running tests with UBSan: runtime error: load of value 4294967295, which is not a valid value for type 'Trigger'.

For enums without a fixed underlying type, casting into them from
numbers outside of their enumeration values is undefined behavior.
Fixes running tests with UBSan: `runtime error: load of value
4294967295, which is not a valid value for type 'Trigger'`.
@github-actions github-actions Bot added the Tests label Apr 24, 2026
@Ghabry Ghabry added this to the 0.8.2 milestone Apr 25, 2026
@Ghabry

Ghabry commented Apr 25, 2026

Copy link
Copy Markdown
Member

Jenkins: test this please

@Ghabry Ghabry merged commit d086756 into EasyRPG:master May 1, 2026
18 checks passed
@staticssleever668 staticssleever668 deleted the fix_enum_cast_ub branch May 1, 2026 15:21
sevenc-nanashi pushed a commit to sevenc-nanashi/easyrpg-player that referenced this pull request May 31, 2026
Return an optional instead of casting -1 into an enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants